#define D2D_INPUT_COUNT 1
#define D2D_INPUT0_COMPLEX
#define D2D_REQUIRES_SCENE_POSITION
#include "d2d1effecthelpers.hlsli"


//半径
float radius;
//开始位置
float2 position;
//目标位置
float2 targetPosition;

float pressure;

D2D_PS_ENTRY(main) {

    //当前位置
    float2 cPoint = D2DGetScenePosition().xy;
    // 计算当前点到目标点距离
    float dist = distance(targetPosition, cPoint);
     if (radius >= dist) {
         //比例因子
         float scaleFactor = 1 - (dist / radius);
         scaleFactor *= pressure;
         float2 dPos = targetPosition - position;
         float x = round(dPos.x);
         float y = round(dPos.y);
         float2 pos = cPoint - mul(scaleFactor, float2(x,y));
        return D2DSampleInputAtPosition(0, pos);
    }
    else {
        return D2DGetInput(0);
    }

}